import { getTeamList } from '../../../../common/api/index'
Page({
    data: {
		tablist: [
			{name:'全部'},
			{name:'直推'},
			{name:'间推'},
		],
		pageNo: 1,
		total: 0,
		dataList: [],
		titleName: null,
		showLoading: false,
    },
    onLoad(options) {
		this.getDataList()
    },
    onShow() {

	},
	// tab切换
	clickTab(e){
		this.setData({
			titleName: e.detail.title,
			pageNo: 1,
		})
		this.getDataList()
	},
	// 获取钱包明细
	getDataList(){
		this.setData({
			showLoading: true
		})
		let data = {
			pageNo: this.data.pageNo,
			pageSize: 10
		}
		if(this.data.titleName === '直推'){
			data.type = 1
		}else if(this.data.titleName === '间推'){
			data.type = 2
		}
		getTeamList(data).then(res => {
			if(res.code == 200){
				let data = []
				if(this.data.pageNo == 1){
					data = res.data
				}else{
					data = this.data.dataList.concat(res.data)
				}
				this.setData({
					dataList: data,
					total: res.extend.total,
					showLoading: false
				})
			}
		})
	},
    //页面上拉触底事件的处理函数
    onReachBottom() {
		if(this.data.total > this.data.dataList.length){
			this.setData({
				pageNo: ++this.data.pageNo,
			})
			this.getDataList()
		}
    },
})